package ssm.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import ssm.domain.Product;

import java.util.List;

@Repository
public interface IProductDao {

    /*对于Dao层，可以不写实现类*/

    //查询所有项目信息  (此处建议把异常抛出)
    @Select("select * from product")
    public List<Product> findAll() throws Exception;

    //根据id进行查询
    @Select({"select * from product where id = #{id}"})
    public Product findById(String id) throws Exception;

    @Insert("insert into product(id,productNum,productName,cityName,DepartureTime,productPrice,productDesc,productStatus) values(#{productNum},#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus})")
    void save(Product product);
}
